home *** CD-ROM | disk | FTP | other *** search
/ PC Play 129 / pc play 129.iso / Demo / man2 / man2.exe / data / scripts / unitsUtilityFunctions.lua < prev    next >
Encoding:
Text File  |  2009-10-29  |  40.7 KB  |  1,363 lines

  1.  
  2.  
  3. executeScript("scripts\\sounds.lua")
  4.  
  5. -- target - unit on which to find free spot
  6. -- firespottype - int == 1 or 2 - type of firespot - for first weapon or second
  7. -- checkForEffectType == int - firespot considered free if it haven't effect of that type
  8.  
  9. function units_findfreefirespot(unit,weaponnumber)
  10.     local firespottype = ENBT_FIRE1
  11.     if(weaponnumber == 2) then firespottype = ENBT_FIRE2 end
  12.     local i = 0
  13.     local place
  14.     while true do
  15.         place = unit:getBone(firespottype,i);
  16.         if(place == nil or place:getFreeCargoSpace() >= 1) then return place end
  17.         i = i + 1
  18.     end
  19. end
  20.  
  21. -- reloads free firespots of weaponType
  22. -- free considered as absense of weaponEffectType effects
  23. function units_reloadfirespots(unit,weaponnumber,weaponEffectType)
  24.     local firespottype = ENBT_FIRE1
  25.     if(weaponnumber == 2) then firespottype = ENBT_FIRE2 end
  26.     local firespot;
  27.     local i = 0
  28.     while true do
  29.         firespot = unit:getBone(firespottype,i)
  30.         if(firespot == nil) then return end
  31.         if(firespot:getFreeCargoSpace() >= 1) then
  32.             firespot:addSimpleEffect(weaponEffectType)
  33.         end
  34.         i = i + 1
  35.     end
  36. end
  37.  
  38. function units_explode(partsDist,explodeType,isShakeCamera)
  39.     local unit = uniGetExecutor()
  40. --    unit:setLifeParams(1,0)
  41.     unit:setTransformOwner()
  42.     unit:play3DSound("bigunitexplode.wav",0):destroy()
  43.  
  44.     -- stop burning effects
  45.  
  46.     local fire
  47.  
  48.     fire = unit:findEffect(ENET_EFFECT_PS_SMALLUNITFIRING)
  49.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  50.     fire = unit:findEffect(ENET_EFFECT_PS_UNITFIRINGBADLY)
  51.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  52.  
  53.     local exp_ps = unit:addSimpleEffect(explodeType)
  54.  
  55.     exp_ps:suspendedDestroy(3.0)
  56.     exp_ps:setTransformOwner()
  57.  
  58.     pause(0.1)
  59.     unit:explode(partsDist)
  60.  
  61.     local ht = getHeightType(unit:getWorldPosition());
  62.     if(isShakeCamera == true and ht ~= ENBHT_WATERHIT) then getCamera():shake(1.0,6.0) end
  63.  
  64.     -- explosion mark
  65.     pause(0.25)
  66.     if(ht ~= ENBHT_WATERHIT) then
  67.         local exp_mark = unit:addSimpleEffect(ENET_EFFECT_DYNAMICGEOMETRY_EXPLOSIONMARK_BIG)
  68.         exp_mark:delayedDestroy(70.0)
  69.         exp_mark:setTransformOwner()
  70. --        local upos = unit:getWorldPosition()
  71. --        getCamera():setLocalPosition(upos.x,upos.y,upos.z - 200)
  72.     end
  73.  
  74.     local wv = unit:findEffect(ENET_EFFECTSEMITTER_SHIPSTANDINGWATERWAVE)
  75.     if(wv ~= nil) then wv:suspendedDestroy(4) end
  76.  
  77.     unit:removeSpaceHoldingEffects();
  78.  
  79.     units_stopFansRadars()
  80.  
  81. end
  82.  
  83. function units_explode_detailed(partsDist,explodeType,isShakeCamera,isRing,lightType)
  84.     local unit = uniGetExecutor()
  85. --    unit:setLifeParams(1,0)
  86.     unit:setTransformOwner()
  87.     unit:play3DSound("bigunitexplode.wav",0):destroy()
  88.  
  89.     -- stop burning effects
  90.  
  91.     local fire
  92.  
  93.     fire = unit:findEffect(ENET_EFFECT_PS_SMALLUNITFIRING)
  94.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  95.     fire = unit:findEffect(ENET_EFFECT_PS_UNITFIRINGBADLY)
  96.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  97.  
  98.     local exp_ps = unit:addSimpleEffect(explodeType)
  99.     local exp_ps_light = unit:addSimpleEffect(lightType)
  100.     if(isRing == true) then 
  101.       --local exp_ps2 = unit:addSimpleEffect(ENET_EFFECT_SP_ENVIRONMENT_EXPLOSION_RING4)
  102.       --exp_ps2:suspendedDestroy(0.8)
  103.     --    pause(0.4)
  104.       local exp_ps2_2 = unit:addSimpleEffect(ENET_EFFECT_SP_ENVIRONMENT_EXPLOSION_RING)
  105.       exp_ps2_2:suspendedDestroy(0.8)
  106.     end
  107.  
  108.     exp_ps:suspendedDestroy(5.0)
  109.     exp_ps:setTransformOwner()
  110.     exp_ps_light:suspendedDestroy(3.0)
  111.  
  112.     pause(0.1)
  113.     unit:explode(partsDist)
  114.  
  115.     local ht = getHeightType(unit:getWorldPosition());
  116.     --if(isShakeCamera == true and ht ~= ENBHT_WATERHIT) then getCamera():shake(1.0,6.0) end
  117.  
  118.     -- explosion mark
  119.     pause(0.25)
  120.     if(ht ~= ENBHT_WATERHIT) then
  121.         local exp_mark = unit:addSimpleEffect(ENET_EFFECT_DYNAMICGEOMETRY_EXPLOSIONMARK_BIG)
  122.         exp_mark:delayedDestroy(70.0)
  123.         exp_mark:setTransformOwner()
  124. --        local upos = unit:getWorldPosition()
  125. --        getCamera():setLocalPosition(upos.x,upos.y,upos.z - 200)
  126.     end
  127.  
  128.     local wv = unit:findEffect(ENET_EFFECTSEMITTER_SHIPSTANDINGWATERWAVE)
  129.     if(wv ~= nil) then wv:suspendedDestroy(4) end
  130.  
  131.     unit:removeSpaceHoldingEffects();
  132.  
  133.     units_stopFansRadars()
  134.  
  135. end
  136.  
  137. function units_explode_detailed2(partsDist,explodeType,isShakeCamera,isRing,lightType)
  138.     local unit = uniGetExecutor()
  139.     unit:setTransformOwner()
  140.     unit:play3DSound("bigunitexplode.wav",0):destroy()
  141.     -- stop burning effects
  142.     local fire
  143.     fire = unit:findEffect(ENET_EFFECT_PS_SMALLUNITFIRING)
  144.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  145.     fire = unit:findEffect(ENET_EFFECT_PS_UNITFIRINGBADLY)
  146.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  147.     if(isRing == true) then 
  148.       local exp_ps2 = unit:addSimpleEffect(ENET_EFFECT_SP_ENVIRONMENT_EXPLOSION_RING)
  149.       exp_ps2:suspendedDestroy(0.8)
  150.     end
  151.  
  152.     local stroke_ps
  153.     local exp_ps_s
  154.     local pos = D3DXVECTOR3:new(0,0,0)
  155.     local exp_ps
  156.     for m = 0,26 do
  157.         pos.x = rand(-50,50)
  158.         pos.y = rand(10,80)
  159.         pos.z = rand(-50,50)
  160.         exp_ps_s = unit:addParticleSystem(ENET_EFFECT_PS_ROCKETEXPLODE,pos.x,pos.y,pos.z)
  161.         stroke_ps = unit:addSimpleEffect(ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BIG3_TRACE2)
  162.         stroke_ps:setLocalPosition(pos.x,pos.y,pos.z)
  163.         stroke_ps:parabolicFly(pos,rand(120,150))
  164.         pause(rand(0,0.15))
  165.         exp_ps_s:suspendedDestroy(2.0)
  166.         stroke_ps:delayedDestroy(1.0)
  167.         if(m == 21) then unit:explode(40) end
  168.         if(m == 16) then exp_ps = unit:addParticleSystem(explodeType,0,10,0) end
  169.     end
  170.     pause(0.6)
  171.     exp_ps:suspendedDestroy(10.0)
  172.     local ht = getHeightType(unit:getWorldPosition())
  173.     -- explosion mark
  174.     pause(0.25)
  175.     if(ht ~= ENBHT_WATERHIT) then
  176.         local exp_mark = unit:addSimpleEffect(ENET_EFFECT_DYNAMICGEOMETRY_EXPLOSIONMARK_BIG)
  177.         exp_mark:delayedDestroy(70.0)
  178.         exp_mark:setTransformOwner()
  179.     end
  180.     local wv = unit:findEffect(ENET_EFFECTSEMITTER_SHIPSTANDINGWATERWAVE)
  181.     if(wv ~= nil) then wv:suspendedDestroy(4) end
  182.     unit:removeSpaceHoldingEffects()
  183.     units_stopFansRadars()
  184.     pos:delete()
  185. end
  186.  
  187. function units_explode_detailed3(partsDist,explodeType,isShakeCamera,isRing,lightType)
  188.     local unit = uniGetExecutor()
  189. --    unit:setLifeParams(1,0)
  190.     unit:setTransformOwner()
  191.     unit:play3DSound("bigunitexplode.wav",0):destroy()
  192.  
  193.     -- stop burning effects
  194.  
  195.     local fire
  196.  
  197.     fire = unit:findEffect(ENET_EFFECT_PS_SMALLUNITFIRING)
  198.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  199.     fire = unit:findEffect(ENET_EFFECT_PS_UNITFIRINGBADLY)
  200.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  201.  
  202.     if(isRing == true) then 
  203.       local exp_ps2 = unit:addSimpleEffect(ENET_EFFECT_SP_ENVIRONMENT_EXPLOSION_RING)
  204.       exp_ps2:suspendedDestroy(0.8)
  205.     end
  206.  
  207.     local pos = D3DXVECTOR3:new(0,0,0)
  208.     local l = 0
  209.     for l = 0,0 do
  210.         local stroke_ps2 = {}
  211.  
  212.         local exp_ps = unit:addSimpleEffect(explodeType)
  213.         local j = 0
  214.             --if(j == 10) then unit:explode(partsDist) end
  215.             unit:explode(partsDist)
  216.  
  217.         for j = 0,60 do
  218.                 pos.x = rand(-20,20)
  219.                 pos.y = rand(15,40)
  220.                 pos.z = rand(-20,20)
  221.             
  222.                 stroke_ps2[j] = unit:addSimpleEffect(ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BIG3_TRACE2)
  223.                 stroke_ps2[j]:setLocalPosition(pos.x,pos.y,pos.z)
  224.  
  225.                 local gravity = createInterpolator()
  226.                 gravity:addKey(0.0,0.0)
  227.                 gravity:addKey(8.0,-250.0)
  228.                 gravity:finalize(false)
  229.  
  230.                 local trajectory = stroke_ps2[j]:parabolicFly(pos,rand(30,80))
  231.                 trajectory:addInterpolator(gravity,getFieldOffset(EN_FIELD_3DPARABOLICMOVER_GRAVITY))
  232.                 --waitDeath(trajectory)
  233.                 
  234.  
  235.         end
  236.         pause(0.7)
  237.         local exp_ps_light = unit:addSimpleEffect(lightType)
  238.         exp_ps:suspendedDestroy(10.0)
  239.         exp_ps:setTransformOwner()
  240.         exp_ps_light:suspendedDestroy(3.0)
  241.         pause(2.3)
  242.         for j = 0,60 do
  243.             stroke_ps2[j]:suspendedDestroy(8.0)
  244.         end
  245.     end
  246.  
  247.     pause(0.6)
  248.  
  249.  
  250.     local ht = getHeightType(unit:getWorldPosition());
  251.     --if(isShakeCamera == true and ht ~= ENBHT_WATERHIT) then getCamera():shake(1.0,6.0) end
  252.  
  253.     -- explosion mark
  254.     pause(0.25)
  255.     if(ht ~= ENBHT_WATERHIT) then
  256.         local exp_mark = unit:addSimpleEffect(ENET_EFFECT_DYNAMICGEOMETRY_EXPLOSIONMARK_BIG)
  257.         exp_mark:delayedDestroy(70.0)
  258.         exp_mark:setTransformOwner()
  259. --        local upos = unit:getWorldPosition()
  260. --        getCamera():setLocalPosition(upos.x,upos.y,upos.z - 200)
  261.     end
  262.  
  263.     local wv = unit:findEffect(ENET_EFFECTSEMITTER_SHIPSTANDINGWATERWAVE)
  264.     if(wv ~= nil) then wv:suspendedDestroy(4) end
  265.  
  266.     unit:removeSpaceHoldingEffects();
  267.  
  268.     units_stopFansRadars()
  269.     pos:delete()
  270.  
  271. end
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279. function units_explode_expert(partsDist,explodeType,isShakeCamera,isRing,lightType,NumOfRays,RayEffect)
  280.     local unit = uniGetExecutor()
  281. --    unit:setLifeParams(1,0)
  282.     unit:setTransformOwner()
  283.     unit:play3DSound("bigunitexplode.wav",0):destroy()
  284.  
  285.     -- stop burning effects
  286.  
  287.     local fire
  288.  
  289.     fire = unit:findEffect(ENET_EFFECT_PS_SMALLUNITFIRING)
  290.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  291.     fire = unit:findEffect(ENET_EFFECT_PS_UNITFIRINGBADLY)
  292.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  293.  
  294.     if(isRing == true) then 
  295.       local exp_ps2 = unit:addSimpleEffect(ENET_EFFECT_SP_ENVIRONMENT_EXPLOSION_RING)
  296.       exp_ps2:suspendedDestroy(0.8)
  297.     end
  298.  
  299.     local pos = D3DXVECTOR3:new(0,0,0)
  300.     local l = 0
  301.     for l = 0,0 do
  302.         local stroke_ps2 = {}
  303.  
  304.         local exp_ps = unit:addSimpleEffect(explodeType)
  305.         local j = 0
  306.             --if(j == 10) then unit:explode(partsDist) end
  307.             unit:explode(partsDist)
  308.  
  309.         for j = 0,NumOfRays do
  310.                 pos.x = rand(-20,20)
  311.                 pos.y = rand(15,40)
  312.                 pos.z = rand(-20,20)
  313.             
  314.                 stroke_ps2[j] = unit:addSimpleEffect(RayEffect)
  315.                 stroke_ps2[j]:setLocalPosition(pos.x,pos.y,pos.z)
  316.  
  317.                 local gravity = createInterpolator()
  318.                 gravity:addKey(0.0,-40.0)
  319.                 gravity:addKey(8.0,-400.0)
  320.                 gravity:finalize(false)
  321.  
  322.                 local trajectory = stroke_ps2[j]:parabolicFly(pos,rand(40,70))
  323.                 trajectory:addInterpolator(gravity,getFieldOffset(EN_FIELD_3DPARABOLICMOVER_GRAVITY))
  324.                 --waitDeath(trajectory)
  325.                 
  326.  
  327.         end
  328.         pause(0.7)
  329.         local exp_ps_light = unit:addSimpleEffect(lightType)
  330.         exp_ps:suspendedDestroy(10.0)
  331.         exp_ps:setTransformOwner()
  332.         exp_ps_light:suspendedDestroy(3.0)
  333.         pause(0.3)
  334.         for j = 0,NumOfRays do
  335.             stroke_ps2[j]:suspendedDestroy(8.0)
  336.         end
  337.     end
  338.  
  339.     pause(0.6)
  340.  
  341.  
  342.     local ht = getHeightType(unit:getWorldPosition());
  343.     --if(isShakeCamera == true and ht ~= ENBHT_WATERHIT) then getCamera():shake(1.0,6.0) end
  344.  
  345.     -- explosion mark
  346.     pause(0.25)
  347.     if(ht ~= ENBHT_WATERHIT) then
  348.         local exp_mark = unit:addSimpleEffect(ENET_EFFECT_DYNAMICGEOMETRY_EXPLOSIONMARK_BIG)
  349.         exp_mark:delayedDestroy(70.0)
  350.         exp_mark:setTransformOwner()
  351. --        local upos = unit:getWorldPosition()
  352. --        getCamera():setLocalPosition(upos.x,upos.y,upos.z - 200)
  353.     end
  354.  
  355.     local wv = unit:findEffect(ENET_EFFECTSEMITTER_SHIPSTANDINGWATERWAVE)
  356.     if(wv ~= nil) then wv:suspendedDestroy(4) end
  357.  
  358.     unit:removeSpaceHoldingEffects();
  359.  
  360.     units_stopFansRadars()
  361.  
  362.     pos:delete()
  363.  
  364. end
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383. function units_explode_basef(partsDist,explodeType,isShakeCamera,isRing,lightType)
  384.     local unit = uniGetExecutor()
  385. --    unit:setLifeParams(1,0)
  386.     unit:setTransformOwner()
  387.     unit:play3DSound("bigunitexplode.wav",0):destroy()
  388.  
  389.     -- stop burning effects
  390.  
  391.     local fire
  392.  
  393.     fire = unit:findEffect(ENET_EFFECT_PS_SMALLUNITFIRING)
  394.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  395.     fire = unit:findEffect(ENET_EFFECT_PS_UNITFIRINGBADLY)
  396.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  397.  
  398.     if(isRing == true) then 
  399.       local exp_ps2 = unit:addSimpleEffect(ENET_EFFECT_SP_ENVIRONMENT_EXPLOSION_RING2)
  400.       exp_ps2:suspendedDestroy(3.0)
  401.     end
  402.     
  403.     pause(0.1)
  404.     local base_exp = unit:addSimpleEffect(ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BASEMENT)
  405.           base_exp:suspendedDestroy(8.0)
  406.  
  407.     local pos = D3DXVECTOR3:new(0,0,0)
  408.  
  409.         local exp_ps_light = unit:addSimpleEffect(lightType)
  410.  
  411.  
  412.         local small_expl = {}
  413.         local j = 0
  414.         for j = 0,5 do
  415.             
  416.             pos.x = rand(-35,35)
  417.             pos.y = rand(15,110)
  418.             pos.z = rand(-30,35)
  419.  
  420.             small_expl[j] = unit:addParticleSystem(ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BASE2,pos.x,pos.y,pos.z)
  421.             pause(rand(0.1,0.4))
  422.             
  423.             if(j == 3) then 
  424.                 local exp_ps = unit:addSimpleEffect(explodeType)         
  425.                 unit:explode(partsDist)
  426.                 exp_ps:suspendedDestroy(10.0)
  427.                 exp_ps:setTransformOwner()
  428.             end
  429.  
  430.         end
  431.  
  432.         local base_exp55 = unit:addSimpleEffect(ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BASEMENT)
  433.               base_exp55:suspendedDestroy(8.0)
  434.  
  435.         pause(0.5)
  436.  
  437.         for j = 0,5 do
  438.             small_expl[j]:suspendedDestroy(6.0)
  439.         end
  440.          
  441.  
  442.         exp_ps_light:suspendedDestroy(3.0)
  443.  
  444.     local exp_smoke = unit:addSimpleEffect(ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BASE_SMOKE)         
  445.     exp_smoke:suspendedDestroy(10.0)
  446.  
  447.     pause(0.6)
  448.  
  449.  
  450.     local ht = getHeightType(unit:getWorldPosition());
  451.     --if(isShakeCamera == true and ht ~= ENBHT_WATERHIT) then getCamera():shake(1.0,6.0) end
  452.  
  453.     -- explosion mark
  454.     pause(0.25)
  455.     if(ht ~= ENBHT_WATERHIT) then
  456.         local exp_mark = unit:addSimpleEffect(ENET_EFFECT_DYNAMICGEOMETRY_EXPLOSIONMARK_BIG)
  457.         exp_mark:delayedDestroy(70.0)
  458.         exp_mark:setTransformOwner()
  459. --        local upos = unit:getWorldPosition()
  460. --        getCamera():setLocalPosition(upos.x,upos.y,upos.z - 200)
  461.     end
  462.  
  463.     local wv = unit:findEffect(ENET_EFFECTSEMITTER_SHIPSTANDINGWATERWAVE)
  464.     if(wv ~= nil) then wv:suspendedDestroy(4) end
  465.  
  466.     unit:removeSpaceHoldingEffects();
  467.  
  468.     units_stopFansRadars()
  469.  
  470.     pos:delete()
  471.  
  472. end
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487. function units_explode_oilplatformf(partsDist,explodeType,isShakeCamera,isRing,lightType)
  488.     local unit = uniGetExecutor()
  489. --    unit:setLifeParams(1,0)
  490.     unit:setTransformOwner()
  491.     unit:play3DSound("bigunitexplode.wav",0):destroy()
  492.  
  493.     -- stop burning effects
  494.  
  495.     local fire
  496.  
  497.     fire = unit:findEffect(ENET_EFFECT_PS_SMALLUNITFIRING)
  498.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  499.     fire = unit:findEffect(ENET_EFFECT_PS_UNITFIRINGBADLY)
  500.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  501.  
  502.     if(isRing == true) then 
  503.       local exp_ps2 = unit:addSimpleEffect(ENET_EFFECT_SP_ENVIRONMENT_EXPLOSION_RING2)
  504.       exp_ps2:suspendedDestroy(3.0)
  505.     end
  506.     
  507.     pause(0.1)
  508.     local base_exp = unit:addSimpleEffect(ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_OILPLATFORMBASEMENT)
  509.           base_exp:suspendedDestroy(8.0)
  510.  
  511.     local pos = D3DXVECTOR3:new(0,0,0)
  512.  
  513.         local exp_ps_light = unit:addSimpleEffect(lightType)
  514.  
  515.  
  516.         local small_expl = {}
  517.         local j = 0
  518.         for j = 0,9 do
  519.             
  520.             pos.x = rand(-1,1)
  521.             pos.y = rand(-100,0)
  522.             pos.z = rand(-1,1)
  523.  
  524.             small_expl[j] = unit:getBone(ENBT_FAN,0):addParticleSystem(ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_OILPLATFORM2,pos.x,pos.y,pos.z)
  525.             pause(rand(0.01,0.05))
  526.             
  527.             if(j == 8) then 
  528.                 local exp_ps = unit:addSimpleEffect(explodeType)         
  529.                 unit:explode(partsDist)
  530.                 exp_ps:suspendedDestroy(10.0)
  531.                 exp_ps:setTransformOwner()
  532.             end
  533.  
  534.         end
  535.  
  536.         local base_exp55 = unit:addSimpleEffect(ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_OILPLATFORMBASEMENT)
  537.               base_exp55:suspendedDestroy(8.0)
  538.  
  539.         pause(0.5)
  540.  
  541.         for j = 0,5 do
  542.             small_expl[j]:suspendedDestroy(6.0)
  543.         end
  544.          
  545.  
  546.         exp_ps_light:suspendedDestroy(3.0)
  547.  
  548.     local exp_smoke = unit:addSimpleEffect(ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_OILPLATFORM_SMOKE)         
  549.     exp_smoke:suspendedDestroy(10.0)
  550.  
  551.     pause(0.6)
  552.  
  553.  
  554.     local ht = getHeightType(unit:getWorldPosition());
  555.     --if(isShakeCamera == true and ht ~= ENBHT_WATERHIT) then getCamera():shake(1.0,6.0) end
  556.  
  557.     -- explosion mark
  558.     pause(0.25)
  559.     if(ht ~= ENBHT_WATERHIT) then
  560.         local exp_mark = unit:addSimpleEffect(ENET_EFFECT_DYNAMICGEOMETRY_EXPLOSIONMARK_BIG)
  561.         exp_mark:delayedDestroy(70.0)
  562.         exp_mark:setTransformOwner()
  563. --        local upos = unit:getWorldPosition()
  564. --        getCamera():setLocalPosition(upos.x,upos.y,upos.z - 200)
  565.     end
  566.  
  567.     local wv = unit:findEffect(ENET_EFFECTSEMITTER_SHIPSTANDINGWATERWAVE)
  568.     if(wv ~= nil) then wv:suspendedDestroy(4) end
  569.  
  570.     unit:removeSpaceHoldingEffects();
  571.  
  572.     units_stopFansRadars()
  573.  
  574.     pos:delete()
  575.  
  576. end
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593. function units_explode_detailed4(partsDist,explodeType,isShakeCamera,isRing,lightType,numofRays)
  594.     local unit = uniGetExecutor()
  595. --    unit:setLifeParams(1,0)
  596.     unit:setTransformOwner()
  597.     unit:play3DSound("bigunitexplode.wav",0):destroy()
  598.  
  599.     -- stop burning effects
  600.  
  601.     local fire
  602.  
  603.     fire = unit:findEffect(ENET_EFFECT_PS_SMALLUNITFIRING)
  604.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  605.     fire = unit:findEffect(ENET_EFFECT_PS_UNITFIRINGBADLY)
  606.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  607.  
  608.     if(isRing == true) then 
  609.       local exp_ps2 = unit:addSimpleEffect(ENET_EFFECT_SP_ENVIRONMENT_EXPLOSION_RING)
  610.       exp_ps2:suspendedDestroy(0.8)
  611.     end
  612.  
  613.     local pos = D3DXVECTOR3:new(0,0,0)
  614.     local l = 0
  615.     for l = 0,0 do
  616.         local stroke_ps2 = {}
  617.  
  618.         local exp_ps = unit:getBone(ENBT_TARGET):addSimpleEffect(explodeType)
  619.         exp_ps:setLocalPosition(0,-30,0)
  620.          
  621.         local j = 0
  622.             unit:explode(partsDist)
  623.  
  624.         for j = 0,numofRays do
  625.                 pos.x = rand(-10,10)
  626.                 pos.y = rand(-10,20)
  627.                 pos.z = rand(-10,10)
  628.             
  629.                 stroke_ps2[j] = unit:getBone(ENBT_TARGET):addSimpleEffect(ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BIG3_TRACE4)
  630.                 stroke_ps2[j]:setLocalPosition(pos.x,pos.y,pos.z)
  631.  
  632.                 local gravity = createInterpolator()
  633.                 gravity:addKey(0.0,-10.0)
  634.                 gravity:addKey(13,-10.0)
  635.                 gravity:finalize(false)
  636.  
  637.                 local trajectory = stroke_ps2[j]:parabolicFly(pos,rand(20,50))
  638.                 trajectory:addInterpolator(gravity,getFieldOffset(EN_FIELD_3DPARABOLICMOVER_GRAVITY))
  639.                 --waitDeath(trajectory)
  640.  
  641.         end
  642.         pause(0.7)
  643.         local exp_ps_light = unit:addSimpleEffect(lightType)
  644.         exp_ps:suspendedDestroy(10.0)
  645.         exp_ps:setTransformOwner()
  646.         exp_ps_light:suspendedDestroy(3.0)
  647.         pause(0.6)
  648.         for j = 0,numofRays do
  649.             stroke_ps2[j]:suspendedDestroy(8.0)
  650.         end
  651.     end
  652.  
  653.     pause(0.6)
  654.  
  655.  
  656.     local ht = getHeightType(unit:getWorldPosition());
  657.     --if(isShakeCamera == true and ht ~= ENBHT_WATERHIT) then getCamera():shake(1.0,6.0) end
  658.  
  659.     -- explosion mark
  660.     pause(0.25)
  661.     if(ht ~= ENBHT_WATERHIT) then
  662.         local exp_mark = unit:addSimpleEffect(ENET_EFFECT_DYNAMICGEOMETRY_EXPLOSIONMARK_BIG)
  663.         exp_mark:delayedDestroy(70.0)
  664.         exp_mark:setTransformOwner()
  665. --        local upos = unit:getWorldPosition()
  666. --        getCamera():setLocalPosition(upos.x,upos.y,upos.z - 200)
  667.     end
  668.  
  669.     local wv = unit:findEffect(ENET_EFFECTSEMITTER_SHIPSTANDINGWATERWAVE)
  670.     if(wv ~= nil) then wv:suspendedDestroy(4) end
  671.  
  672.     unit:removeSpaceHoldingEffects();
  673.  
  674.     units_stopFansRadars()
  675.  
  676.     pos:delete()
  677.  
  678. end
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691. function units_explode_det_water(partsDist,explodeType,isShakeCamera,isRing,lightType)
  692.     local unit = uniGetExecutor()
  693. --    unit:setLifeParams(1,0)
  694.     unit:setTransformOwner()
  695.     unit:play3DSound("bigunitexplode.wav",0):destroy()
  696.  
  697.     -- stop burning effects
  698.  
  699.     local fire
  700.  
  701.     fire = unit:findEffect(ENET_EFFECT_PS_SMALLUNITFIRING)
  702.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  703.     fire = unit:findEffect(ENET_EFFECT_PS_UNITFIRINGBADLY)
  704.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  705.  
  706.     local exp_ps = unit:addSimpleEffect(explodeType)
  707.     local exp_ps_light = unit:addSimpleEffect(lightType)
  708.     if(isRing == true) then 
  709.       local exp_ps2 = unit:addSimpleEffect(ENET_EFFECT_SP_ENVIRONMENT_EXPLOSION_RING)
  710.       exp_ps2:suspendedDestroy(0.8)
  711.     end
  712.  
  713.     exp_ps:suspendedDestroy(8.0)
  714.     exp_ps:setTransformOwner()
  715.     exp_ps_light:suspendedDestroy(3.0)
  716.  
  717.     pause(0.1)
  718.     unit:explode(partsDist)
  719.  
  720.     local ht = getHeightType(unit:getWorldPosition());
  721.     if(isShakeCamera == true and ht ~= ENBHT_WATERHIT) then getCamera():shake(1.0,6.0) end
  722.  
  723.     -- explosion mark
  724.     pause(0.25)
  725.     if(ht ~= ENBHT_WATERHIT) then
  726.         local exp_mark = unit:addSimpleEffect(ENET_EFFECT_DYNAMICGEOMETRY_EXPLOSIONMARK_BIG)
  727.         exp_mark:delayedDestroy(70.0)
  728.         exp_mark:setTransformOwner()
  729. --        local upos = unit:getWorldPosition()
  730. --        getCamera():setLocalPosition(upos.x,upos.y,upos.z - 200)
  731.     end
  732.  
  733.     local wv = unit:findEffect(ENET_EFFECTSEMITTER_SHIPSTANDINGWATERWAVE)
  734.     if(wv ~= nil) then wv:suspendedDestroy(4) end
  735.  
  736.     unit:removeSpaceHoldingEffects();
  737.  
  738.     units_stopFansRadars()
  739. end
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753. function units_explode_det_water2(partsDist,explodeType,isShakeCamera,isRing,lightType)
  754.     local unit = uniGetExecutor()
  755. --    unit:setLifeParams(1,0)
  756.     unit:setTransformOwner()
  757.     unit:play3DSound("bigunitexplode.wav",0):destroy()
  758.  
  759.     -- stop burning effects
  760.  
  761.     local fire
  762.  
  763.     fire = unit:findEffect(ENET_EFFECT_PS_SMALLUNITFIRING)
  764.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  765.     fire = unit:findEffect(ENET_EFFECT_PS_UNITFIRINGBADLY)
  766.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  767.  
  768.     if(isRing == true) then 
  769.       local exp_ps2 = unit:addSimpleEffect(ENET_EFFECT_SP_ENVIRONMENT_EXPLOSION_RING)
  770.       exp_ps2:suspendedDestroy(0.8)
  771.     end
  772.  
  773.  
  774.     local pos = D3DXVECTOR3:new(0,0,0)
  775.     local l = 0
  776.     for l = 0,0 do
  777.         local stroke_ps2 = {}
  778.  
  779.         local exp_ps = unit:addSimpleEffect(explodeType)
  780.         local j = 0
  781.  
  782.         for j = 0,60 do
  783.             local nw = 0
  784.             nw = rand(0,20)    
  785.  
  786.             if(j == 10) then unit:explode(partsDist) end
  787.                 pos.x = rand(-30,30)
  788.                 pos.y = rand(5,40)
  789.                 pos.z = rand(-30,30)
  790.             
  791.                 stroke_ps2[j] = unit:addSimpleEffect(ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BIG3_TRACE3)
  792.                 stroke_ps2[j]:setLocalPosition(pos.x,pos.y,pos.z)
  793.  
  794.                 local gravity = createInterpolator()
  795.                 gravity:addKey(0.0,120.0)
  796.                 gravity:addKey(1.2,-220.0)
  797.                 gravity:addKey(4.8,0.0)
  798.                 gravity:addKey(13.0,0.0)
  799.                 gravity:finalize(false)
  800.  
  801.                 local trajectory = stroke_ps2[j]:parabolicFly(pos,rand(20,60))
  802.                 trajectory:addInterpolator(gravity,getFieldOffset(EN_FIELD_3DPARABOLICMOVER_GRAVITY))
  803.                 
  804.  
  805.         end
  806.         pause(0.7)
  807.         local exp_ps_light = unit:addSimpleEffect(lightType)
  808.         exp_ps:suspendedDestroy(13.0)
  809.         exp_ps:setTransformOwner()
  810.         exp_ps_light:suspendedDestroy(3.0)
  811.         pause(4.8)
  812.         for j = 0,60 do
  813.             stroke_ps2[j]:suspendedDestroy(5.0)
  814.         end
  815.     end
  816.  
  817.     local ht = getHeightType(unit:getWorldPosition());
  818.     if(isShakeCamera == true and ht ~= ENBHT_WATERHIT) then getCamera():shake(1.0,6.0) end
  819.  
  820.     -- explosion mark
  821.     pause(0.25)
  822.     if(ht ~= ENBHT_WATERHIT) then
  823.         local exp_mark = unit:addSimpleEffect(ENET_EFFECT_DYNAMICGEOMETRY_EXPLOSIONMARK_BIG)
  824.         exp_mark:delayedDestroy(70.0)
  825.         exp_mark:setTransformOwner()
  826. --        local upos = unit:getWorldPosition()
  827. --        getCamera():setLocalPosition(upos.x,upos.y,upos.z - 200)
  828.     end
  829.  
  830.     local wv = unit:findEffect(ENET_EFFECTSEMITTER_SHIPSTANDINGWATERWAVE)
  831.     if(wv ~= nil) then wv:suspendedDestroy(4) end
  832.  
  833.     unit:removeSpaceHoldingEffects();
  834.  
  835.     units_stopFansRadars()
  836.  
  837.     pos:delete()
  838.  
  839. end
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855. function units_explode_det_water3(partsDist,explodeType,isShakeCamera,isRing,lightType)
  856.     local unit = uniGetExecutor()
  857. --    unit:setLifeParams(1,0)
  858.     unit:setTransformOwner()
  859.     unit:play3DSound("bigunitexplode.wav",0):destroy()
  860.  
  861.     -- stop burning effects
  862.  
  863.     local fire
  864.  
  865.     fire = unit:findEffect(ENET_EFFECT_PS_SMALLUNITFIRING)
  866.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  867.     fire = unit:findEffect(ENET_EFFECT_PS_UNITFIRINGBADLY)
  868.     if(fire ~= nil) then fire:suspendedDestroy(1.0) end
  869.  
  870.     if(isRing == true) then 
  871.       local exp_ps2 = unit:addSimpleEffect(ENET_EFFECT_SP_ENVIRONMENT_EXPLOSION_RING)
  872.       exp_ps2:suspendedDestroy(0.8)
  873.     end
  874.  
  875.  
  876.     local pos = D3DXVECTOR3:new(0,0,0)
  877.     local l = 0
  878.     for l = 0,0 do
  879.         local stroke_ps2 = {}
  880.  
  881.         local exp_ps = unit:addSimpleEffect(explodeType)
  882.         local j = 0
  883.  
  884.         for j = 0,30 do
  885.             local nw = 0
  886.             nw = rand(0,20)    
  887.  
  888.             if(j == 10) then unit:explode(partsDist) end
  889.                 pos.x = rand(-30,30)
  890.                 pos.y = rand(2,20)
  891.                 pos.z = rand(-30,30)
  892.             
  893.                 stroke_ps2[j] = unit:addSimpleEffect(ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BIG3_TRACE3)
  894.                 stroke_ps2[j]:setLocalPosition(pos.x,pos.y,pos.z)
  895.  
  896.                 local gravity = createInterpolator()
  897.                 gravity:addKey(0.0,-80.0)
  898.                 gravity:addKey(1.2,-80.0)
  899.                 gravity:addKey(4.8,0.0)
  900.                 gravity:addKey(13.0,0.0)
  901.                 gravity:finalize(false)
  902.  
  903.                 local trajectory = stroke_ps2[j]:parabolicFly(pos,rand(20,80))
  904.                 trajectory:addInterpolator(gravity,getFieldOffset(EN_FIELD_3DPARABOLICMOVER_GRAVITY))
  905.                 
  906.  
  907.         end
  908.         pause(0.7)
  909.         local exp_ps_light = unit:addSimpleEffect(lightType)
  910.         exp_ps:suspendedDestroy(13.0)
  911.         exp_ps:setTransformOwner()
  912.         exp_ps_light:suspendedDestroy(3.0)
  913.         pause(4.8)
  914.         for j = 0,30 do
  915.             stroke_ps2[j]:suspendedDestroy(5.0)
  916.         end
  917.     end
  918.  
  919.     local ht = getHeightType(unit:getWorldPosition());
  920.     if(isShakeCamera == true and ht ~= ENBHT_WATERHIT) then getCamera():shake(1.0,6.0) end
  921.  
  922.     -- explosion mark
  923.     pause(0.25)
  924.     if(ht ~= ENBHT_WATERHIT) then
  925.         local exp_mark = unit:addSimpleEffect(ENET_EFFECT_DYNAMICGEOMETRY_EXPLOSIONMARK_BIG)
  926.         exp_mark:delayedDestroy(70.0)
  927.         exp_mark:setTransformOwner()
  928. --        local upos = unit:getWorldPosition()
  929. --        getCamera():setLocalPosition(upos.x,upos.y,upos.z - 200)
  930.     end
  931.  
  932.     local wv = unit:findEffect(ENET_EFFECTSEMITTER_SHIPSTANDINGWATERWAVE)
  933.     if(wv ~= nil) then wv:suspendedDestroy(4) end
  934.  
  935.     unit:removeSpaceHoldingEffects();
  936.  
  937.     units_stopFansRadars()
  938.  
  939.     pos:delete()
  940.  
  941. end
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953. function units_explode_xxl1()
  954.     units_explode_detailed2(200.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BIG3,true,true,ENET_EFFECT_EXPLOSION_LIGHT2)
  955. end
  956.  
  957. function units_explode_big()
  958.     units_explode(200.0,ENET_EFFECT_PS_BIGUNITEXPLODE,true)
  959. end
  960.  
  961. function units_explode_small()
  962.     units_explode(50.0,ENET_EFFECT_PS_SMALLUNITEXPLODE,false)
  963. end
  964.  
  965. function units_explode_small1()
  966.     local rr = rand(0,4)
  967.     if (rr < 1) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION1,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  968.     if (rr >= 1 and rr < 2) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION2,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  969.     if (rr >= 2 and rr < 3) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION1_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  970.     if (rr >= 3 and rr <= 4) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION2_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  971. end
  972.  
  973. function units_explode_small2()
  974.     local rr = rand(0,4)
  975.     if (rr < 1) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION1,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  976.     if (rr >= 1 and rr < 2) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION2,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  977.     if (rr >= 2 and rr < 3) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION1_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  978.     if (rr >= 3 and rr <= 4) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION2_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  979. end
  980.  
  981. function units_explode_small3()
  982.     local rr = rand(0,6)
  983.     if (rr < 1) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION3,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  984.     if (rr >= 1 and rr < 2) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION4,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  985.     if (rr >= 2 and rr < 3) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION3_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  986.     if (rr >= 3 and rr < 4) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION4_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  987.     if (rr >= 4 and rr < 5) then units_explode_detailed(70.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION5,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  988.     if (rr >= 5 and rr <= 6) then units_explode_detailed(70.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION6,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  989. end
  990.  
  991. function units_explode_small4()
  992.     local rr = rand(0,6)
  993.     if (rr < 1) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION3,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  994.     if (rr >= 1 and rr < 2) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION4,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  995.     if (rr >= 2 and rr < 3) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION3_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  996.     if (rr >= 3 and rr < 4) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION4_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  997.     if (rr >= 4 and rr < 5) then units_explode_detailed(70.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION5,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  998.     if (rr >= 5 and rr <= 6) then units_explode_detailed(70.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION6,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  999. end
  1000.  
  1001. function units_explode_small1_green()
  1002.     local rr = rand(0,4)
  1003.     if (rr < 1) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION1,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  1004.     if (rr >= 1 and rr < 2) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION2,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  1005.     if (rr >= 2 and rr < 3) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION1_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  1006.     if (rr >= 3 and rr <= 4) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION2_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  1007. end
  1008.  
  1009. function units_explode_small2_green()
  1010.     local rr = rand(0,4)
  1011.     if (rr < 1) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION1,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  1012.     if (rr >= 1 and rr < 2) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION2,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  1013.     if (rr >= 2 and rr < 3) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION1_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  1014.     if (rr >= 3 and rr <= 4) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION2_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  1015. end
  1016.  
  1017. function units_explode_small3_green()
  1018.     local rr = rand(0,6)
  1019.     if (rr < 1) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION3,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  1020.     if (rr >= 1 and rr < 2) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION4,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  1021.     if (rr >= 2 and rr < 3) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION3_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  1022.     if (rr >= 3 and rr < 4) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION4_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  1023.     if (rr >= 4 and rr < 5) then units_explode_detailed(70.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION5,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  1024.     if (rr >= 5 and rr <= 6) then units_explode_detailed(70.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION6,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  1025. end
  1026.  
  1027. function units_explode_small4_green()
  1028.     local rr = rand(0,6)
  1029.     if (rr < 1) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION3,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  1030.     if (rr >= 1 and rr < 2) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION4,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  1031.     if (rr >= 2 and rr < 3) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION3_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  1032.     if (rr >= 3 and rr < 4) then units_explode_detailed(50.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION4_GREEN,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  1033.     if (rr >= 4 and rr < 5) then units_explode_detailed(70.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION5,false,true,ENET_EFFECT_EXPLOSION_LIGHT1) end
  1034.     if (rr >= 5 and rr <= 6) then units_explode_detailed(70.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION6,false,true,ENET_EFFECT_EXPLOSION_LIGHT1_GREEN) end
  1035. end
  1036.  
  1037. function units_explode_big1()
  1038. --[[
  1039.     if rand(0,2) > 1 then
  1040.         units_explode_detailed(150.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BIG1,true,true,ENET_EFFECT_EXPLOSION_LIGHT1)
  1041.     else
  1042.         units_explode_detailed(150.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BIG2,true,true,ENET_EFFECT_EXPLOSION_LIGHT2)
  1043.     end
  1044. ]]--
  1045.         units_explode_detailed(150.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BIG2,true,true,ENET_EFFECT_EXPLOSION_LIGHT2)
  1046. end
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057. function units_explode_fire()
  1058.     units_explode_detailed4(150.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BIG1B,true,true,ENET_EFFECT_EXPLOSION_LIGHT3,5)
  1059. end
  1060.  
  1061. function units_explode_xxl2()
  1062.     units_explode_detailed3(200.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BIG4,true,true,ENET_EFFECT_EXPLOSION_LIGHT3)
  1063. end
  1064.  
  1065. function units_explode_water1()
  1066.     units_explode_det_water2(200.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_WATER1,true,true,ENET_EFFECT_EXPLOSION_LIGHT1)
  1067. end
  1068.  
  1069. function units_explode_water2()
  1070.     units_explode_det_water3(150.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_WATER2,true,true,ENET_EFFECT_EXPLOSION_LIGHT1)
  1071. end
  1072.  
  1073. function units_explode_water3()
  1074.     units_explode_det_water(100.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_WATER3,true,true,ENET_EFFECT_EXPLOSION_LIGHT1)
  1075. end
  1076.  
  1077.  
  1078. function units_explode_water4()
  1079.     units_explode_det_water(100.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_WATER4,true,true,ENET_EFFECT_EXPLOSION_LIGHT1)
  1080. end
  1081.  
  1082. function units_explode_xxl3()
  1083.     units_explode_expert(200.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BIG5,true,true,ENET_EFFECT_EXPLOSION_LIGHT3,15,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BIG3_TRACE5)
  1084. end
  1085.  
  1086. function units_explode_base()
  1087.     units_explode_basef(10.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_BASE,true,true,ENET_EFFECT_EXPLOSION_LIGHT4)
  1088. end
  1089.  
  1090. function units_explode_oilplatform()
  1091.     units_explode_oilplatformf(10.0,ENET_EFFECT_PS_ENVIRONMENT_EXPLOSION_OILPLATFORM,true,true,ENET_EFFECT_EXPLOSION_LIGHT4)
  1092. end
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099. function building_setup(shadowType)
  1100.     units_setup(4,false,nil,shadowType)
  1101.     local unit = uniGetExecutor()
  1102.     local nBones = unit:getBonesCount()
  1103.     local i
  1104.     local bone
  1105.     for i = 0,nBones-1 do
  1106.         bone = unit:getBone(ENBT_TOTAL,i)
  1107.         if bone:getScriptSet() ~= ENSCRIPTSET_TARGETBONE then
  1108.             bone:setScriptSet(ENSCRIPTSET_BASE_BONE)
  1109.         end
  1110.     end
  1111.     unit:addMaskRender(ENMAT_CAPITAL_MASK)
  1112. end
  1113.  
  1114. function units_setup(maxLifePoints,isRed,smokeType,shadowType,isNotRotateFans,isPlaySound)
  1115.     maxLifePoints = uniGetMaxLife()
  1116.     local unit = uniGetExecutor()
  1117.     isRed = false
  1118.     if(unit:getUID() < 4096) then isRed = true end
  1119.     if(isPlaySound == nil) then
  1120.         unit:play3DSound("setup.wav",0):destroy()
  1121.     end
  1122.     if(smokeType ~= nil and uniGetTarget() == nil) then
  1123.         local smoke = unit:addSimpleEffect(smokeType)
  1124.         smoke:setTransformOwner()
  1125.         smoke:suspendedDestroy(2.0)
  1126.     end
  1127.     if(shadowType ~= nul) then unit:addSimpleEffect(shadowType) end
  1128.     if(maxLifePoints < 1000) then
  1129.         if(isRed) then unit:addLifeIndicator(0,1,0,0)
  1130.                   else unit:addLifeIndicator(0,0,1,0)
  1131.         end
  1132.     end
  1133.     unit:setLifeParams(maxLifePoints,uniGetLife())
  1134.     unit:resetBones()
  1135.     unit:resetAnimations()
  1136.     unit:addSimpleEffect(ENET_EFFECT_BOUNDEDTEXT)
  1137.  
  1138.     while(unit:getScale() < 1.0) do
  1139.         unit:setScale(1,1,1)
  1140.         pause()
  1141.     end
  1142.     unit:setVisibility(true,true)
  1143.  
  1144.     local owner = uniGetTarget()
  1145.     if(owner) then
  1146.         unit:setTransformOwner(units_findfreefirespot(owner,1))
  1147.         unit:setLocalPosition(0,0,0)
  1148.         unit:setLocalOrientation(0,1,0,0,0,1)
  1149.         if(owner:getIsPlacesVisible() == false) then
  1150.             unit:setVisibility(false,false)
  1151.         end
  1152.     end
  1153.     if(isNotRotateFans == nil) then
  1154.         units_rotateFansRadars()
  1155.     end
  1156.  
  1157.     if( IsCommanderUnit(unit:getUID()) ) then
  1158.         local bone = unit:getBone(ENBT_FLAG)
  1159.         if(bone ~= nil) then
  1160.             local f = 1
  1161.             if(isRed)    then f = bone:addSimpleEffect(ENET_EFFECT_GEOMETRY_ROCKETEXPLODE)
  1162.                         else f = bone:addSimpleEffect(ENET_EFFECT_GEOMETRY_FATEST) end
  1163.             f:setLocalOrientation(0,1,0,0,0,-1)
  1164.             if(    unit:getScriptSet() ~= ENSCRIPTSET_HELICOPTER and unit:getScriptSet() ~= ENSCRIPTSET_HELICOPTER_ALIEN)
  1165.             then f:setScale(3.0,3.0,3.0)
  1166.             else f:setScale(2.0,2.0,2.0) end
  1167.         end
  1168.     end
  1169.  
  1170. end
  1171.  
  1172. function units_setup_sea(max_hp,isRed,isSetup,shadowType)
  1173.     units_setup(max_hp,isRed,nil,shadowType)
  1174.     local unit = uniGetExecutor()
  1175.     unit:addSimpleEffect(ENET_EFFECT_ROTATE_SHIP)
  1176.     --unit:addSimpleEffect(ENET_EFFECTSEMITTER_SHIPSTANDINGWATERWAVE)
  1177.  
  1178.     unit:addSimpleEffect(ENET_EFFECTEMITTER_WATERTRAY)
  1179.     if(isSetup == true) then
  1180.         local wave;
  1181.         wave = unit:addSimpleEffect(ENET_EFFECT_BINDEDSPRITE_WATERSHOCKWAVE_SHIPSETUP)
  1182.         wave:delayedDestroy(2.0)
  1183.         wave:setTransformOwner()
  1184.         wave = unit:addSimpleEffect(ENET_EFFECT_BINDEDSPRITE_WATERSHOCKWAVE_SHIPSETUP1)
  1185.         wave:delayedDestroy(2.0)
  1186.         wave:setTransformOwner()
  1187.         wave = unit:addSimpleEffect(ENET_EFFECT_BINDEDSPRITE_WATERSHOCKWAVE_SHIPSETUP2)
  1188.         wave:delayedDestroy(2.0)
  1189.         wave:setTransformOwner()
  1190.         wave = unit:addSimpleEffect(ENET_EFFECT_BINDEDSPRITE_WATERSHOCKWAVE_SHIPSETUP3)
  1191.         wave:delayedDestroy(2.0)
  1192.         wave:setTransformOwner()
  1193.     end
  1194.  
  1195. end
  1196.  
  1197. function units_unselect()
  1198.     local unit = uniGetExecutor()
  1199. --    unit:killEffect(ENET_EFFECT_ROTATE_RADAR)
  1200. --    unit:killEffect(ENET_EFFECT_GEOMETRY_ALLYSELECT)
  1201.     unit:killEffect(ENET_EFFECT_UNIT_SELECTION)
  1202.     unit:killEffect(ENET_EFFECT_GEOMETRY_FIRERANGE)
  1203.     unit:killEffect(ENET_EFFECT_SELECTEDGEOMETRY_ENEMY)
  1204.     unit:killEffect(ENET_EFFECT_GEOMETRY_HIGHLIGHT)
  1205.     
  1206. end
  1207.  
  1208. function units_select(selectionRadius,fireRangeRadius)
  1209.     units_unselect()
  1210.     local unit = uniGetExecutor()
  1211.     if(selectionRadius > 0) then
  1212. --        unit:addEffectWithRadius(ENET_EFFECT_GEOMETRY_ALLYSELECT,selectionRadius)
  1213. --        unit:addEffectWithRadius(ENET_EFFECT_UNIT_SELECTION,selectionRadius):addRotationEffect(ENET_EFFECT_ROTATE_RADAR,-1 * MATH_PI / 4)
  1214.         local sel = unit:addSimpleEffect( ENET_EFFECT_UNIT_SELECTION )
  1215.         addTextureRotation( sel, -math.pi / 4, 0.5, 0.5 )
  1216.     end
  1217.     if(uniGetMaxLife() ~= 0) then
  1218.         unit:addEffectWithRadius(ENET_EFFECT_GEOMETRY_FIRERANGE,getHexRadius(uniGetMaxLife()))
  1219.     end
  1220. end
  1221.  
  1222. function units_executesimplecommand()
  1223.     uniGetExecutor():executeInternalCommand()
  1224. end
  1225.  
  1226. function units_inside()
  1227.     pause(100000)
  1228. end
  1229.  
  1230. function units_waitCommandByUID(unit,UID)
  1231.     while(true) do
  1232.         if(unit:getCurrentCommandUID() == UID) then break end
  1233.         pause()
  1234.     end
  1235. end
  1236.  
  1237. function units_minLoadSize(unit)
  1238.     local box_size = unit:getBBoxSize()
  1239.     local scale = 6.5 / box_size
  1240.     if(scale > 0.75) then scale = 0.75 end
  1241.     return scale
  1242. end
  1243.  
  1244. function units_unload_growth(unit)
  1245.     if(unit:getScale() < 0.8) then
  1246.         local load_effect = unit:addSimpleEffect(ENET_EFFECT_PS_STRANSPORT_LIGHTING)
  1247.         load_effect:delayedDestroy(2.7)
  1248.         load_effect:setTransformOwner()
  1249.         interpolator = createInterpolator()
  1250.         interpolator:addKey(0.0,units_minLoadSize(unit))
  1251.         interpolator:addKey(0.2,1.0)
  1252.         interpolator:finalize(false)
  1253.         unit:addInterpolator(interpolator,getFieldOffset(EN_FIELD_SCALE_X),true)
  1254.         unit:addInterpolator(interpolator,getFieldOffset(EN_FIELD_SCALE_Y),true)
  1255.         unit:addInterpolator(interpolator,getFieldOffset(EN_FIELD_SCALE_Z),true)
  1256.         pause(0.2)
  1257.         load_effect:suspendedDestroy(2.5)
  1258.     end
  1259. end
  1260.  
  1261. function units_load_shrink(unit)
  1262.     if(unit:getScale() > 0.8) then
  1263.         local load_effect = unit:addSimpleEffect(ENET_EFFECT_PS_STRANSPORT_LIGHTING)        
  1264.         load_effect:delayedDestroy(2.7)
  1265.         load_effect:setTransformOwner()
  1266.         interpolator = createInterpolator()
  1267.         interpolator:addKey(0.0,1.0)
  1268.         interpolator:addKey(0.2,units_minLoadSize(unit))
  1269.         interpolator:finalize(false)
  1270.         unit:addInterpolator(interpolator,getFieldOffset(EN_FIELD_SCALE_X),true)
  1271.         unit:addInterpolator(interpolator,getFieldOffset(EN_FIELD_SCALE_Y),true)
  1272.         unit:addInterpolator(interpolator,getFieldOffset(EN_FIELD_SCALE_Z),true)
  1273.         pause(0.2)
  1274.         load_effect:suspendedDestroy(2.5)
  1275.     end
  1276. end
  1277.  
  1278. function units_addGround(unit,g_type)
  1279.     local ground = unit:addSimpleEffect(g_type)
  1280.     ground:setTransformOwner()
  1281.     ground:setVisibility(false,false)
  1282.     local groundHolder = enHolder:new(ground,HT_DESTROYER)
  1283.     return groundHolder
  1284. end
  1285.  
  1286. function units_rotateFansRadars()
  1287.     local unit = uniGetExecutor()
  1288.     local fan
  1289.     local i = 0
  1290.     while true do
  1291.         fan = unit:getBone(ENBT_FAN,i)
  1292.         if(fan == nil) then break end
  1293.         local speed = rand(MATH_PI * 1.0,MATH_PI * 2.0)
  1294.         if(rand(0,10) < 5) then speed = -speed end
  1295.         fan:addRotationEffect(ENET_EFFECT_ROTATE_RADAR,speed)
  1296.         i = i + 1
  1297.     end
  1298.     i = 0
  1299.     while true do
  1300.         fan = unit:getBone(ENBT_RADAR,i)
  1301.         if(fan == nil) then break end
  1302.         local speed = rand(MATH_PI * 0.5,MATH_PI * 0.8)
  1303.         if(rand(0,10) < 5) then speed = -speed end
  1304.         fan:addRotationEffect(ENET_EFFECT_ROTATE_RADAR,speed)
  1305.         i = i + 1
  1306.     end
  1307. end
  1308.  
  1309. function units_stopFansRadars()
  1310.     local unit = uniGetExecutor()
  1311.     local fan
  1312.     local i = 0
  1313.     while true do
  1314.         fan = unit:getBone(ENBT_FAN,i)
  1315.         if(fan == nil) then break end
  1316.         local rotor = fan:findEffect(ENET_EFFECT_ROTATE_RADAR)
  1317.         if(rotor ~= nil) then rotor:destroy() end
  1318.         rotor = fan:findEffect(ENET_EFFECT_ROTATE_WHEEL)
  1319.         if(rotor ~= nil) then rotor:destroy() end
  1320.         i = i + 1
  1321.     end
  1322.     i = 0
  1323.     while true do
  1324.         fan = unit:getBone(ENBT_RADAR,i)
  1325.         if(fan == nil) then break end
  1326.         local rotor = fan:findEffect(ENET_EFFECT_ROTATE_RADAR)
  1327.         if(rotor ~= nil) then rotor:destroy() end
  1328.         i = i + 1
  1329.     end
  1330. end
  1331.  
  1332. function units_rotateWheels()
  1333.     local unit = uniGetExecutor()
  1334.     local wheel
  1335.     local i = 0
  1336.     while true do
  1337.         wheel = unit:getBone(ENBT_WHEEL,i)
  1338.         if(wheel == nil) then break end
  1339.         wheel:addRotationEffect(ENET_EFFECT_ROTATE_WHEEL,MATH_PI * 5)
  1340.         i = i + 1
  1341.     end
  1342. end
  1343.  
  1344. function units_stopWheels()
  1345.     local unit = uniGetExecutor()
  1346.     local wheel
  1347.     local i = 0
  1348.     while true do
  1349.         wheel = unit:getBone(ENBT_WHEEL,i)
  1350.         if(wheel == nil) then break end
  1351.         local rotor = wheel:findEffect(ENET_EFFECT_ROTATE_WHEEL)
  1352.         if(rotor ~= nil) then rotor:destroy() end
  1353.         i = i + 1
  1354.     end
  1355. end
  1356.  
  1357. function wait_for_platform(unit)
  1358.     if (unit:getTransformOwner() ~= nil) then
  1359.         local carrier = unit:getTransformOwner():getTransformOwner()
  1360.         while(carrier:getCurrentCommandUID() < 2000000000) do pause() end
  1361.     else
  1362.     end
  1363. end